package com.cmc.cloud.cmclink.doc.util.sepcial;

import com.cmc.cloud.cmclink.doc.constants.DgCommodityConstants;
import com.cmc.cloud.cmclink.doc.constants.errorconstant.DgCommodityErrorCodeConstants;
import com.cmes.framework.common.exception.util.ServiceExceptionUtil;
import org.apache.tika.utils.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 危险品品名util
 * 
 * @author dev89
 * @date 2025/07/11 12:34
 **/
public class DgCommodityUtil {
    public static void validVersionValid(String version) {
        if (StringUtils.isEmpty(version)) {
            throw ServiceExceptionUtil.exception(DgCommodityErrorCodeConstants.DG_COMMODITY_VERSION_INVALID);
        }

        Pattern pattern = Pattern.compile(DgCommodityConstants.VERSION_NO_REGEX);
        // 创建Matcher对象
        Matcher matcher = pattern.matcher(version);
        if (!matcher.matches()) {
            throw ServiceExceptionUtil.exception(DgCommodityErrorCodeConstants.DG_COMMODITY_VERSION_INVALID);
        }
    }
}
